package com.chen.springcloud.controller;

import com.chen.springcloud.entity.Dept;
import com.chen.springcloud.service.DeptClientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName
 * @Description:    消费者，不应该有 service 层
 *                  RestTemplate …… 里面有很多模板 可以咱直接 调用 {用这个去请求}
 * @Author:
 * @Date: Created in 21:43 2022/5/22
 */
@RestController
@RequestMapping("/feignDeptConsumer")
public class FeignDeptConsumerController {

    @Autowired
    private DeptClientService deptClientService;

    /**
     *  保存部门信息
     * @param dept
     * @return
     */
    @RequestMapping("/saveDeptInfo")
    public Boolean saveDeptInfo(Dept dept){
        return deptClientService.saveDeptInfo(dept);
    }

    /**
     *  通过id 查询部门
     * @param id
     * @return
     */
    @RequestMapping("/queryDeptById/{id}")
    public Dept queryDeptById(@PathVariable("id") Integer id){
        return deptClientService.queryDeptById(id);
    }

    /**
     *  查询所有部门
     * @return
     */
    @RequestMapping("/queryDeptAll")
    public List<Dept> queryDeptAll(){
        return deptClientService.queryDeptAll();
    }


}
